package com.wk.warehouse.service.impl;

import java.util.HashMap;
import java.util.List;
import com.wk.warehouse.entity.Transshipment;
import com.wk.warehouse.mapper.TransshipmentMapper;
import com.wk.warehouse.page.Page;
import com.wk.warehouse.service.TransshipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TransshipmentServiceImp implements TransshipmentService {

	@Autowired
	private TransshipmentMapper transshipmentMapper;

	// 模糊查询所有仓库信息
	@Override
	public List<Transshipment> selectTransshipment(Transshipment transshipment, Page page) {
		HashMap<String, Object> map = new HashMap<>();
		map.put("transshipment", transshipment);
		map.put("page", page);
		return transshipmentMapper.selectTransshipment(map);
	}

	// 查询调货单总数
	@Override
	public int transshipmentCount(Transshipment transshipment) {
		HashMap<String, Object> map = new HashMap<>();
		map.put("transshipment", transshipment);
		return transshipmentMapper.transshipmentCount(map);
	}

	/**
	 * 添加调货表
	 */
	public Integer addTransshipment(Transshipment transshipment){
		return transshipmentMapper.addTransshipment(transshipment);
	}

	/**
	 * 修改调货状态为已审核
	 */
	@Override
	public int updateAuditState(int transId) {
		return transshipmentMapper.updateAuditState(transId);
	}

	//完成调货修改源仓库原商品数量
	@Override
	public int updateSourceNum(Transshipment transshipment) {
		return transshipmentMapper.updateSourceNum(transshipment);
	}

}
